package com.nami.store.api.service;

import com.nami.store.api.bo.UserDevice;
import com.nami.store.api.bo.UserDeviceDetailInfo;
import com.nami.store.api.bo.UserWrap;
import com.nami.store.api.request.cache.CacheDelReq;
import com.nami.store.api.request.cache.SeqRequest;
import com.nami.store.api.request.login.UserQryRequest;

import java.util.List;
import java.util.Map;


/**
 * 描述：
 *
 * @Author: lbc
 * @Date: 2023-08-13 15:42
 * @email: 594599620@qq.com
 * @Description: keep coding
 */
public interface RemoteL2CacheService {

    /**
     * 生成自增会话seq
     *
     * @param sequenceDTO
     * @return
     */
    Long incrSeq(SeqRequest sequenceDTO);

    /**
     * 是否是重复消息
     *
     * @param prefix
     * @param messageId
     * @return
     */
    boolean isRepeatMessage(String prefix, String messageId);

    /**
     * 获取用户在线的客户端
     *
     * @param appKey
     * @param userId
     * @param excludeDeviceType
     * @return
     */
    List<UserDevice> getOnlineClientForUserNo(String appKey, String userId, Integer excludeDeviceType);

    /**
     * 缓存添加用户信息
     *
     * @param userWrap
     * @return
     */
    boolean updOnrUser(UserWrap userWrap);

    /**
     * 移除用户
     *
     * @param request
     * @return
     */
    boolean removeOfflineUser(CacheDelReq request);

    /**
     * 保存消息id
     *
     * @param appKey
     * @param clientMsgId
     * @return
     */
    boolean storeTempMsgId(String appKey, String clientMsgId);

    /**
     * 获取用户
     *
     * @param appKey
     * @param userId
     * @return
     */
    UserWrap getOnrUser(String appKey, String userId);

    /**
     * 批量获取在线用户
     *
     * @param appKey
     * @param userIds
     * @return
     */
    List<UserWrap> getOnrUsers(String appKey, List<String> userIds);

    /**
     * 获取缓存信息
     *
     * @param userList
     * @return
     */
    List<UserDeviceDetailInfo> getOnrUserDevices(String key, List<String> userList);

    /**
     * 查询缓存是否有信息
     *
     * @param searchDTO
     * @return
     */
    UserDevice getOnrUserDeivceInfoByDeviceType(UserQryRequest searchDTO);

    /**
     * ip 分组
     *
     * @param key
     * @param userList
     * @return
     */
    Map<String, List<UserDeviceDetailInfo>> getOnrUserDevicesClassifiedByGateNo(String key, List<String> userList);

    /**
     * 按照mq分组
     *
     * @param appKey
     * @param userList
     * @return
     */
    Map<String, List<UserDeviceDetailInfo>> getOnlineUserDevicesClassifiedByMqTag(String appKey, List<String> userList);

    /**
     * exist
     *
     * @param key
     * @return
     */
    boolean isRunningTask(String key);

    boolean isExistByKey(String key);

    /**
     * @param key
     * @return
     */
    boolean set(String key, Object value);

    boolean delElementByKey(String key);

}
